// Object.h - an object which has an ID and position;
// base class for most in-game objects, and direct superclass for point lights.
// Could also be used as a lightweight end-effector for cameras.
//
// Nick Kitten
// 2009

#pragma once

#include <string>
#include <list>
#include <set>
#include "DarkGDK.h"
#include "Utilities.h"

using namespace std;




class Object
{
public:
	Object();
	Object( int id, float x = 0, float y = 0, float z = 0 );
	Object( int id, Triple pos ) : ID( id ), position( pos ) {}
	virtual ~Object();

	inline int getID() const;				// return the object's ID

	Triple getPosition() const;		// return a copy of the object's positition
	float getPosX() const;			// return the x coordinate of the position
	float getPosY() const;			// return the y coordinate of the position
	float getPosZ() const;			// return the z coordinate of the position

	virtual void setPosition(float x, float y, float z);		// set the object's current position
	void setPosition( Triple pos ) { setPosition( pos.x, pos.y, pos.z ); }

	void constrainToPosition( Object * child, string axes = "xyz" );
	bool removePositionConstraint( Object * child, string axes = "xyz" );

	// WARNING: it is possible to give two different objects the same ID,
	// or to have objects of different types (camera, light) compare as equal
	// with this implementation.  Use with caution.
	inline bool operator==( const Object & rhs )
	{
		return ( this->getID() == rhs.getID() );
	}

protected:
	Triple position;
	int ID;

	// Used for applying transformations from one object to any number of children
	typedef struct PositionConstraint
	{
		Object * obj;
		std::set<char> axes;
	} PositionConstraint;

	list< PositionConstraint > positionChildren;
};
